package com.yt.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.naming.AuthenticationException;

@ControllerAdvice
@Slf4j
public class PermissionsControllerAdvice {
    @ResponseBody
    @ExceptionHandler(AuthorizationException.class)
    public String ExceptionInfo(Exception e){
        log.info(e.getMessage());
        return "没有权限";
    }
    @ResponseBody
    @ExceptionHandler(AuthenticationException.class)
    public String AuthenticationException(Exception e){
        log.info(e.getMessage());
        return "认证失败";
    }

}
